exports.attendancePreview = (req, res) => {

    //获取参数信息
    var bodyParams = req.routeInfo.bodyParams;
    
    var userData = {};

    //查询所有员工
    function searchUser(cb) {

        R.SEND_HTTP(
            req,
            res,
            {
                url: CORE_APIConfig.coreAPI.userSearch.Request_Api_Url + "/u_is_delete/0/skip/0/limit/1000",
                method: 'POST',
                data: {
                    fields: ["u_id","u_nickname"].join(",")
                }
            },
            function (data) {

                userData = data.result.data;
                
                cb();

            }
        )
    }
    
     //循环获取每个员工的打卡记录
    function searchUserPunch(cb){

        F.SerialEach(userData,function(item,index,callback){

            R.SEND_HTTP(
                req,
                res,
                {
                    url: CORE_APIConfig.coreAPI.punchSearch.Request_Api_Url + 
                    "/opr_uid/" + 
                    item.u_id + 
                    "/opr_year/" + 
                    bodyParams.opr_year + 
                    "/opr_month/" + 
                    bodyParams.opr_month + 
                    "/opr_is_delete/0/skip/0/limit/1000",
                    method : 'GET'
                },
                function (data) {        

                    var temp = 0;
                    for(var ss=0;ss<data.result.data.length;ss++){
                    	if(data.result.data[ss].opr_late_time>0){
                    		temp++;
                    	}
                    }
                    item.punchCount = data.result.data.length;
                    item.lateCount = temp;

                    callback();

                }
            )

        },cb);

    }

    F.Serial([searchUser,searchUserPunch], () => {
        RES.successResponse(res,userData);
    })
}